﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PIB.Models;

namespace PIB.Controllers
{
    public class BeheerVakController : Controller
    {
        //
        // GET: /BeheerVak/

        public ActionResult Index()
        {
            Vak vak = new Vak();
            return View(vak.Index());
        }

        //
        // GET: /BeheerVak/Details/5

        public ActionResult Details(int id = 0)
        {
            Vak vak = new Vak();
            vak = vak.Details(id);
            if (vak == null)
            {
                return HttpNotFound();
            }
            return View(vak);
        }

        //
        // GET: /BeheerVak/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /BeheerVak/Create

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create(Vak vak)
        {
            if (ModelState.IsValid)
            {
                vak.Create(vak);
                return RedirectToAction("Index");
            }

            return View(vak);
        }

        //
        // GET: /BeheerVak/Edit/5

        public ActionResult Edit(int id = 0)
        {
            Vak vak = new Vak();
            vak = vak.Edit(id);
                
            if (vak == null)
            {
                return HttpNotFound();
            }
            return View(vak);
        }

        //
        // POST: /BeheerVak/Edit/5

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit(Vak vak)
        {
            if (ModelState.IsValid)
            {
                Vak vak2 = new Vak();
                vak.Edit(vak);
                return RedirectToAction("Index");
            }
            return View(vak);
        }

        //
        // GET: /BeheerVak/Delete/5

        public ActionResult Delete(int id = 0)
        {
            Vak vak = new Vak();
            vak.Delete(id);
                
            if (vak == null)
            {
                return HttpNotFound();
            }
            return View(vak);
        }

        //
        // POST: /BeheerVak/Delete/5

        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            Vak vak = new Vak();
            vak.DeleteConfirmed(id);


            return RedirectToAction("Index");
        }

        [HttpPost]
        public ActionResult GetDocenten(Vak vak)
        {
            if (ModelState.IsValid)
            {
                string keuze = Request["DocentID"];
            //    vak.VoerKeuzesDoor(Vak.DropDownList.Beoordelaar);
                return RedirectToAction("DatabaseDoorzoekenAandoening");
            }

            return View(vak);
        }



        protected override void Dispose(bool disposing)
        {
            Vak vak = new Vak();
            vak.Dispose(disposing);
            base.Dispose(disposing);
        }
    }
}